﻿@using BL.Entities
@model IEnumerable<BL.Entities.FileSystemEntite>


@*Выделение папок\файлов*@
@Scripts.Render("~/Scripts/Slava/selectable.js")



@Html.Partial("_FolderStruct")

    @*<p id="feedback">
        <span>You've selected:</span> <span id="select-result">none</span>
    </p>*@


@*Костыль хранить в валуе значение сколько есче можно загрузить файлов*@
<button id="AllowedSize"value="@ViewBag.AllowedSize" style="visibility:hidden"></button>

    <p><h1 id="CurrentFolder"> @ViewBag.CurrentFolder<div style="float: right; margin-right: 70px; ">Storage: @ViewBag.StorageCapacity of @ViewBag.AllowedCapacity<div id="statusfile" style="background: linear-gradient(to right, green @ViewBag.PercentSpaceInStorage%, orange @ViewBag.PercentSpaceInStorage%);"></div></div></h1></p>

    <div id="divfilelist">
        <ul id="selectable">
            @foreach (BL.Entities.FileSystemEntite fs in Model)
            {
                if (fs is BL.Entities.Folder)
                {
                    <li class="ui-widget-content">
                        <a class="folderlink" href="@fs.Id" name="@fs.Name, @fs.Owner, @fs.DateCreate.ToString("dd.MM.yyyy"), @fs.DateUpdate.ToString("dd.MM.yyyy")"><img src="~/Content/folder150.png" width="35" height="35" />@fs.Name </a>
                                              
                        <button class="deleteFolder" value="@fs.Id" name="@fs.Name"><img src="~/Content/remove.png" width="30" height="30" style="vertical-align:middle" /></button>
                        <button class="share" value="@fs.Id" onclick="javascript: SharePopUp(-@fs.Id)"><img src="~/Content/share2.png" width="30" height="30" style="vertical-align:middle" /></button>
                        <button class="editFolder" value="@fs.Id, folder" name="@fs.Name"><img src="~/Content/edit.png" width="30" height="30" style="vertical-align:middle" /></button>
                        <button class="downloadfolder" value="@fs.Id"><img src="~/Content/download.png" width="30" height="30" style="vertical-align:middle" /></button>

                    </li>
                }
                else
                {
                    //for file info
                    var file = (BL.Entities.File)fs;
                    
                    <li class="ui-widget-content">                        
                        <a class="filelink" href="@fs.Id" name="@file.Name, @file.Size, @file.Owner, @file.DateCreate.ToString("dd.MM.yyyy"), @file.DateUpdate.ToString("dd.MM.yyyy")"> <img src=@fs.Icon width="40" height="40" />@fs.Name </a>
                        <button class="deleteFile" value="@fs.Id" name="@fs.Name"><img src="~/Content/remove.png" width="30" height="30" style="vertical-align:middle" /></button>
                        @*<button class="share" value="@fs.Id" onclick="javascript: PopUpShowFile(@fs.Id)">Share</button>*@
                        <button class="share" value="@fs.Id" onclick="javascript: SharePopUp(+@fs.Id)"><img src="~/Content/share2.png" width="30" height="30" style="vertical-align:middle" /></button>
                        <button class="editFile" value="@fs.Id, file" name="@fs.Name"><img src="~/Content/edit.png" width="30" height="30" style="vertical-align:middle" /></button>
                        <button class="downloadfile" value="@fs.Id"><img src="~/Content/download.png" width="30" height="30" style="vertical-align:middle" /></button>
                        
                    </li>
                }
            }
        </ul>
    </div>


<script>
    var formats = "css txt js sql java cs html cshtml config ";

    $.each($('.filelink'), function () {

        var ext = $(this).text().split('.');
        ext = ext[ext.length - 1];

        var re = new RegExp(ext);

        if (formats.match(re) != null) {
            $(this).append('<img class="editimg" src="/Content/editor.png" alt="edit">');
        }
    });
    
</script>



    @*Скрипт для ходьбы по папкам\навигационе меню*@
    @Scripts.Render("~/Scripts/Slava/folder.js")

    @*Скачивание файла\папки*@
    @Scripts.Render("~/Scripts/Slava/download.js")

    @*Удаляем*@
    @Scripts.Render("~/Scripts/Dima/delete.js")

    @Scripts.Render("~/Scripts/Dima/edit.js")

    @Scripts.Render("~/Scripts/Dima/name_edit.js")